'use strict'

//const pool = require('./a.js');
//const fun = require('./function.js');

class dailypoem {
  constructor() {
    this.param = '/'
  }

  async get(c) {

    let {user_id} = c.query
    //let {p} = JSON.parse('{"p":5}')
    //console.log(user_id);
    let a = c.service.fun;

    c.setHeader('content-type', 'text/html; charset=utf-8')
    let list = await a.sel('poem_list',"",["poem_id"],c.service.pool)
    let randomnum = Math.round(Math.random()*60);
    let {poem_id} = list.rows[randomnum];
    //console.log(poem_id);
    let data =await a.sel('poem_list',{'poem_id':poem_id},["poem_name","poet","poem_txt","poem_img"],c.service.pool);
    c.send({
      type:'array',
      data:data.rows
      //data:data.rows
    })
  }
 
}

module.exports = dailypoem;

